package StringDemo;

import java.util.Arrays;

public class Demo {
	public static void main(String args[]){
		String s1 = new String("fuck");
		String s2 = "fuck";
		String s3 = new String(new char[]{'s','b'});
		//一般方法：
		//1）length()
		System.out.println(s1.length());
		//2)isEmpty()
		System.out.println(s1.isEmpty());
		//(3)subString(int beginIndex)截取字符串
		System.out.println(s1.substring(2));
		System.out.println(s1.substring(2,3));
		//5)indexOf(char c)
		System.out.println(s1.indexOf('c'));  //2
		System.out.println(s1.lastIndexOf('f'));
		String s4 = "FUCK";
		System.out.println(s1.equalsIgnoreCase(s4));
		String str = "FUck";
		//判断是否以FU开头
		System.out.println(str.startsWith("FU"));
		System.out.println(str.endsWith("ck"));
		System.out.println(str.charAt(2));
		String s5=str.replace('c', 'C');  //返回一个新的字符串
		System.out.println(str);
		System.out.println(s5);
		String s6 = "  fuck   ";
		String s7 = s6.trim();
		System.out.println(s6);
		System.out.println(s7);
		String ups6 = s6.toUpperCase();
		System.out.println(ups6);
		System.out.println(str.concat(s2));
		System.out.println(Arrays.toString(s1.toCharArray()));
		//构造方法
		String str12 = new String(new char[]{'b','c','u','d','f','e'},3,2);
		System.out.println(str12); //df
	}
}
